<template>
  <view>
    <Table ref="table" :fetchData="fetchData">
      <template #default="{ data }">
        <view v-for="(item,index) in data" :key="index">
          <uni-card @click="cardClick(item)">
            <view class="uni-body">
              <view class="title">
                <view class="title-left">
                  <view class="title-title">
                    {{ item.hiddenCheckType }}
                  </view>
                  <span class="title-times" v-if="item.hiddenProgress">
                    {{ item.hiddenProgress }}
                  </span>
                </view>
                <view class="hiddenFrom" v-if="item.hiddenFrom">
                  {{ item.hiddenFrom }}  
                </view>
              </view>
              <view>
                {{ item.hiddenInfo }}
              </view>
              <view
                style="
                  font-size: 12px;
                  display: flex;
                  justify-content: space-between;
                  width: 100%;
                "
              >
                <text style="color: orange">
                  {{ item.hiddenCheckTime }}
                </text>
                <text style="flex: end">
                  {{ item.hiddenType }}  
                </text>
              </view>
            </view>
          </uni-card>
        </view>
      </template>
    </Table>
    <AddButton
      @click="onAddClick"
      v-hasPermi="['preventionHiddenRegister:create']"
    ></AddButton>
  </view>
</template>

<script setup>
import { ref, onActivated } from "vue";
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import Table from "@/components/uniList.vue";
import { useAsyncData } from "@/hooks/useAsyncData.js";
import { apis as APIS } from "@/api/yhpc/yhdj.js";
import { router } from "@/router/index.js";
import { PATH } from "./index.t";
import AddButton from "@/components/addButton.vue";
import Card from "@/components/Card.vue";
const onAddClick = () => {
  uni.setStorage({
    YHDJ: JSON.stringify({}),
  });
  router.toPage({
    path: PATH.INPUT,
  });
};
const cardClick = (item) => {
  console.log(' hiddenFrom ',item.hiddenFrom)
  if(item.hiddenFrom == '专项检查'){
    let data = {
      isAdd: item.hiddenProgress == '待确认' || item.hiddenProgress == '待审核' ? true : false,
      hiddenInventoryId: item.hiddenId
    }
    uni.navigateTo({
      url: `/pages/zxjc/yhgl/index?row=${decodeURIComponent(JSON.stringify(data))}`
    })
  } else{
    uni.setStorage({
      YHDJ: JSON.stringify(item),
    });
    router.toPage({
      path: PATH.INPUT,
      params: {
        row: JSON.stringify(item),
      },
    });
  }
};
const table = ref();

const { fetchData, getList } = useAsyncData({ table, APIS:{
  ...APIS,
  // query:APIS.querydj
} });
onShow(() => {
  getList();
});
</script>

<style lang="scss" scoped>
.button-box {
  // display: flex;
  position: relative;
  flex-wrap: wrap;
  justify-content: start;
  .mini-btn {
    margin: 0 5rpx;
  }
}
.close {
  position: absolute;
  top: -5rpx;
  right: -25rpx;
  color: skyblue !important;
}
.title {
  position: relative;
  display: flex;
  justify-content: space-between;

  &-left {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }
  &-title {
    font-weight: 600;
  }
  &-times {
    background-color: rgb(22, 119, 255);
    padding: 2px;
    font-size: 12px;
    line-height: 15px;
    border-top-left-radius: 10px;
    border-bottom-right-radius: 10px;
    margin-left: 5px;
    color: #fff;
  }
  .hiddenFrom{
    position: absolute;
    top: 0;
    right: -10rpx;
    font-size: 24rpx;
    width: 122rpx;
    height: 48rpx;
    color: #c55a11cf;
    line-height: 48rpx;
    text-align: center;
    border-radius: 48rpx;
    background-color: #f8f0eb;
  }
}
</style>
